<?php
namespace app\admin\validate;

use think\Validate;
use think\Db;

class Goods extends Validate
{

    // 验证规则
    protected $rule = [
        'num_iid'=> 'require|number|gt:0',
        'title' => 'require|min:3|max:150|unique:goods',
        'pic_url'=>'require',
        'volume'=> 'require',
        'price' => 'require',
        'discount_price' => 'require|regex:\d{1,10}(\.\d{1,2})?$',
        'cate_id' => 'number|gt:0',
    ];


    //错误信息
    protected $message = [
        'num_iid.require' => '淘宝IID必须填写',
        'title.require' => '商品标题必填',
        'title.min' => '商品标题长度至少3个字符',
        'title.max' => '商品标题长度至多50个汉字',
        'pic_url.require' => '商品图片必须上传',
        'volume.require' => '销量必填',
        'price.require' => '原价必填',
        'discount_price.require' => '折扣价必填',
        'cate_id.number' => '商品分类必须填写',
        'cate_id.gt' => '商品分类必须选择',
    ];

}